import tui from '../../../common/httpRequest'
const db = wx.cloud.database()

Page({
    data: {
        modal: false,
        password: '',
        list: {},
        content: '点击自动复制网盘链接，按照相应的网盘标签 前往手机网盘app自动打开  持续更新中...'
    },

    onLoad: function (options) {
        db.collection('resource').get().then(res => {
            this.setData({
                list: res.data
            }).catch(err => {
            })
        })

    },
    clipboard: function (e) {
        let item = e.currentTarget.dataset.item;
        wx.setClipboardData({
            data: item,
            success: function (res) {
                wx.showToast({
                    title: '复制成功',
                    icon: 'none',
                    duration: 1000
                })
            }
        })
    },
    search(e) {
        var that = this;
        that.setData({
            Text: e.detail.value
        });
        const arr = that.data.list.filter(
            el => el.text.includes(that.data.Text)
        );
        that.data.list = arr;
        that.setData({
            list: that.data.list
        });
        tui.toast('检索成功：' + e.detail.value)
    },
    onClick(e) {
        this.setData({
            modal: true
        })

    },
    input(e) {
        this.setData({
            password: e.detail.value
        })
    },
    hide() {
        this.setData({
            modal: false
        })
    },
    login() {
        if (this.data.password == 'sdpt1') {
            tui.href("../../../Packages/admin/pages/resource/add")
        } else if (this.data.password == 'sdpt2') {
            tui.href("../../../Packages/admin/pages/goods/add")
        }
        this.hide();
    },
    onReady: function () {

    },


    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})